package org.example.myerp.controller;

import org.example.myerp.dto.RoleDto;
import org.example.myerp.pojo.PageMyself;
import org.example.myerp.pojo.Role;
import org.example.myerp.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

//@CrossOrigin(methods = { RequestMethod.POST, RequestMethod.GET }, allowCredentials = "true", allowedHeaders = "*")

@RestController
@RequestMapping("/system/role")
public class RoleController {
	@Autowired
    RoleService roleServcie;

	@RequestMapping("/findByPage")
	public PageMyself<Role> findByPage(Integer pageNum, Integer pageSize) {
		return roleServcie.findByPage(pageNum, pageSize);
	}

	@RequestMapping("/addRole")
	public void addRole(Role role) {
		roleServcie.addRole(role);
	}

	@RequestMapping("/updateRole")
	public void updateRole(Role role) {
		roleServcie.updateRole(role);
	}

	@RequestMapping("/batchDelRole")
	public void batchDelRole(int[] rids) {
		roleServcie.batchDelRole(rids);
	}
	@RequestMapping("/setRoleMenu")
	public void setRoleMenu(Integer rid, Integer[] mids) {
		roleServcie.setRoleMenu(rid, mids);
	}
	@RequestMapping("/roleDto")
	public RoleDto roleDto(Integer uid) {
		return roleServcie.roleDto(uid);
	}
}
